package dao.impl;

import dao.UserDao;
import domain.User;
import lombok.Data;
import org.springframework.jdbc.datasource.DataSourceUtils;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;

/**
 * Created by pengfei on 2016/12/7.
 */
@Data
public class UserDaoImpl implements UserDao{
    private DataSource dataSource;
    public void addUser(User user) throws Exception{
        Connection conn = DataSourceUtils.getConnection(dataSource);
        PreparedStatement ps = conn.prepareStatement("insert into user(name,sex)values('"+user.getName()+"',"+user.getSex()+")");
        ps.execute();
        System.out.println("执行完成");

        int a = 1/0;

        System.out.println("addUser ...");
    }

    public void updateUser(User user) throws Exception {

    }
}
